package sojo.com.inverter.enums;

/**
 * @author cheng_hu
 * @description:
 * @date 2023-02-25 17:53:22
 */
public enum InverterStateEnum {

    //0x0000 待机：初始化
    INVERTER_STATE_0(0, "待机：初始化"),
    //0x0001 待机：绝缘阻抗检测
    INVERTER_STATE_1(1, "待机：绝缘阻抗检测"),
    //0x0002 待机：光照检测
    INVERTER_STATE_2(2, "待机：光照检测"),
    //0x0003 待机：电网检测
    INVERTER_STATE_3(3, "待机：电网检测"),
    //0x0100 启动
    INVERTER_STATE_4(256, "启动"),
    //0x0200 并网（离网模式：运行）
    INVERTER_STATE_5(512, "并网（离网模式：运行）"),
    //0x0201 并网:限功率（离网模式：运行:限功率）
    INVERTER_STATE_6(513, "并网:限功率（离网模式：运行:限功率）"),
    //0x0202 并网:自降额（离网模式：运行:自降额）
    INVERTER_STATE_7(514, "并网:自降额（离网模式：运行:自降额）"),
    //0x0300 关机：异常关机
    INVERTER_STATE_8(768, "关机：异常关机"),
    //0x0301 关机：指令关机
    INVERTER_STATE_9(769, "关机：指令关机"),
    //0x0302 关机：OVGR
    INVERTER_STATE_10(770, "关机：OVGR"),
    //0x0303 关机：通信断链
    INVERTER_STATE_11(771, "关机：通信断链"),
    //0x0304 关机：限功率
    INVERTER_STATE_12(772, "关机：限功率"),
    //0x0305 关机：需手动开机
    INVERTER_STATE_13(773, "关机：需手动开机"),
    //0x0306 关机：直流开关断开
    INVERTER_STATE_14(774, "关机：直流开关断开"),
    //0x0307 关机：快速关断
    INVERTER_STATE_15(775, "关机：快速关断"),
    //0x0308 关机：输入欠功率
    INVERTER_STATE_16(776, "关机：输入欠功率"),
    //0x0401 电网调度：cosϕ-P 曲线
    INVERTER_STATE_17(1025, "电网调度：cosϕ-P 曲线"),
    //0x0402 电网调度：Q-U曲线
    INVERTER_STATE_18(1026, "电网调度：Q-U 曲线"),
    //0x0403 电网调度：PF-U曲线
    INVERTER_STATE_19(1027, "电网调度：PF-U 曲线"),
    //0x0404 电网调度：干接点
    INVERTER_STATE_20(1028, "电网调度：干接点"),
    //0x0405 电网调度：Q-P曲线
    INVERTER_STATE_21(1029, "电网调度：Q-P 曲线"),
    //0x0500 点检就绪
    INVERTER_STATE_22(1280, "点检就绪"),
    //0x0501 点检中
    INVERTER_STATE_23(1281, "点检中"),
    //0x0600 巡检中
    INVERTER_STATE_24(1536, "巡检中"),
    //0X0700 AFCI自检
    INVERTER_STATE_25(1792, "AFCI自检"),
    //0X0800 IV扫描中
    INVERTER_STATE_26(2048, "IV扫描中"),
    //0X0900 直流输入检测
    INVERTER_STATE_27(2304, "直流输入检测"),
    //0X0A00 运行：脱网充电
    INVERTER_STATE_28(2560, "运行：脱网充电"),
    //0xA000 待机：无光照
    INVERTER_STATE_29(40960, "待机：无光照"),
    ;


    private int stateId;
    private String stateName;

    InverterStateEnum(int stateId, String stateName) {
        this.stateId = stateId;
        this.stateName = stateName;
    }

    public String getStateName(int stateId) {
        for (InverterStateEnum stateEnum : InverterStateEnum.values()) {
            if (stateId == stateEnum.getStateId()) {
                return stateEnum.getStateName();
            }
        }
        return null;
    }

    public int getStateId() {
        return stateId;
    }

    public void setStateId(int stateId) {
        this.stateId = stateId;
    }

    public String getStateName() {
        return stateName;
    }

    public void setStateName(String stateName) {
        this.stateName = stateName;
    }
}
